<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
<script>
var model = {
	name: "wiz",
	isShow: true,
}
// Object.defineProperty(model, "name", {
// 	// value: "wiz2",
// 	// writable: false,//是否可写
// 	enumerable: true,//是否可枚举
// 	configurable: true,//是否以后还可以配置name属性
// 	set: function(value) {
// 		console.log("getter!!!1");
// 		this.value = value;
// 	},
// 	get: function() {
// 		console.log("getter!!!1");
// 		return this.value;
// 	}
// });
function ObserverFactory(model) {
	for(var prop in model) {
		addServer(model, prop, model[prop]);
	}
}
function addServer(model, prop, value) {
	Object.defineProperty(model, prop, {
		enumerable: true,
		configurable: true,
		set: function(nvalue) {
			console.log("setter!!!");
			value = nvalue;
		},
		get: function() {
			console.log("getter!!!");
			return value;
		}
	});
}
ObserverFactory(model);
model.name = "abc";
console.log(Object.getOwnPropertyDescriptor(model, "name"));
</script>
</body>
</html>